package com.dcruitment.dcruitmentindex.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dcruitment.dcruitmentindex.mapper.ClassMapper;
import com.dcruitment.dcruitmentindex.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dcruitment.dcruitmentindex.entity.Class;
import java.util.List;

/**
 * @ProjectName: decheng
 * @Package: com.decheng.dechengindex.service.impl
 * @ClassName: ClassserviceImpl
 * @Author: lfh
 * @Description:
 * @Date: 2020/3/23 14:33
 * @Version: 1.0
 */
@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private ClassMapper classMapper;
    @Override
    public List<Class> getClassList() {
        return    classMapper.getList(0);
    }

    public List<Class> getList(Integer pid){
        QueryWrapper<Class> classQueryWrapper = new QueryWrapper<>();
        classQueryWrapper.eq("pid",pid);
        List<Class> classes = classMapper.selectList(classQueryWrapper);
        if(classes!=null){
            for (Class aClass : classes) {
                aClass.setList(getList(aClass.getId()));
            }
        }
        return classes;
    }
}
